define([],function(){
	// var route = new VueRoute(){
	//  routes:[
	//    {path:'/home',component:Home},
	//    {path:'/user',component:User},
	// ]
	// }
	function Route(option) {
		this.routes = option.routes;
		this.init()
	}
	Route.prototype ={
		constructor: Route,
		init(){
			let _that = this;
			// 监听路由变化
			window.addEventListener('hashchange',function(){
				//1.1获取最新的hash值
				let hash = location.hash.substring(1);//去掉hash的#
				//1.2根据hash跟本地保存的路由中path进行匹配，匹配到指定路由，就执行指定模块的代码
				let route = _that.routes.find(item=>{
					return item.path === hash
				})
				//如果找到符合条件的元素，那么route为空
				if(route){
					route.component()
				}
			})
		}
	}
	return Route;
})